home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / base-min.h < prev    next >
C/C++ Source or Header  |  1996-03-03  |  3KB  |  131 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_base_min_h)
  24. #define octave_base_min_h 1
  25.  
  26. #include "dColVector.h"
  27.  
  28. class
  29. base_minimizer
  30. {
  31. public:
  32.  
  33.   base_minimizer (void) : x () { }
  34.  
  35.   base_minimizer (const ColumnVector& xx) : x (xx) { }
  36.  
  37.   base_minimizer (const base_minimizer& a) : x (a.x) { }
  38.  
  39.   virtual ~base_minimizer (void) { }
  40.  
  41.   base_minimizer& operator = (const base_minimizer& a)
  42.     {
  43.       if (this != &a)
  44.     x = a.x;
  45.  
  46.       return *this;
  47.     }
  48.  
  49.   // Derived classes must provide a function to actually do the
  50.   // minimization.
  51.  
  52.   virtual ColumnVector do_minimize (double& objf, int& inform,
  53.                     ColumnVector& lambda) = 0;
  54.  
  55.   // Lots of ways to call the single function and optionally set and
  56.   // get additional information.
  57.  
  58.   virtual ColumnVector minimize (void)
  59.     {
  60.       double objf;
  61.       int inform;
  62.       ColumnVector lambda;
  63.       return do_minimize (objf, inform, lambda);
  64.     }
  65.  
  66.   virtual ColumnVector minimize (double& objf)
  67.     {
  68.       int inform;
  69.       ColumnVector lambda;
  70.       return do_minimize (objf, inform, lambda);
  71.     }
  72.  
  73.   virtual ColumnVector minimize (double& objf, int& inform)
  74.     {
  75.       ColumnVector lambda;
  76.       return do_minimize (objf, inform, lambda);
  77.     }
  78.  
  79.   virtual ColumnVector minimize (double& objf, int& inform,
  80.                  ColumnVector& lambda)
  81.     {
  82.       return do_minimize (objf, inform, lambda);
  83.     }
  84.  
  85.   virtual ColumnVector minimize (const ColumnVector& x0)
  86.     {
  87.       x = x0;
  88.       double objf;
  89.       int inform;
  90.       ColumnVector lambda;
  91.       return do_minimize (objf, inform, lambda);
  92.     }
  93.  
  94.   virtual ColumnVector minimize (const ColumnVector& x0, double& objf)
  95.     {
  96.       x = x0;
  97.       int inform;
  98.       ColumnVector lambda;
  99.       return do_minimize (objf, inform, lambda);
  100.     }
  101.  
  102.   virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
  103.                  int& inform)
  104.     {
  105.       x = x0;
  106.       ColumnVector lambda;
  107.       return do_minimize (objf, inform, lambda);
  108.     }
  109.  
  110.   virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
  111.                  int& inform, ColumnVector& lambda)
  112.     {
  113.       x = x0;
  114.       return do_minimize (objf, inform, lambda);
  115.     }
  116.  
  117.   int size (void) const { return x.capacity (); }
  118.  
  119. protected:
  120.  
  121.   ColumnVector x;
  122. };
  123.  
  124. #endif
  125.  
  126. /*
  127. ;;; Local Variables: ***
  128. ;;; mode: C++ ***
  129. ;;; End: ***
  130. */
  131.